var express = require('express');
var router = express.Router();


/**
 * @swagger
 * definitions:
 *   StudentModel:     #学生的数据类型  
 *     properties:     #属性
 *       id:
 *         type: string
 *       name:
 *         type: string
 *       gender:
 *         type: string
 */

//---------------------------------------------------

/**
 * @swagger
 * /student:  # 方法的路径
 *   get:          # 请求的方法
 *     tags:          #一个标签把表示那个模块的
 *       - 种猪模块
 *     description: 查询所有的学生
 *     produces:
 *       - application/json   #数据的返回类型
 *     responses:
 *       200:     # 响应码
 *         description: 返回种猪的数组
 *         schema:
 *           $ref: '#/definitions/StudentModel'
 */

//查询所有学生
router.get('/', function(req, res, next) {
  res.json({'code':0,'msg':'查询成功','data':[
      {'id':'12','name':"zhangsan",'gender':'男'},
      {'id':'123','name':"lisi",'gender':'女'},
      {'id':'1234','name':"wangwu",'gender':'男'}
  ]});
});

//查询学生详细
/**
 * @swagger
 * /student/{stuId}/{stuname}:
 *   get:
 *     tags:
 *       - 种猪模块
 *     description: 返回单个种猪
 *     produces:
 *       - application/json
 *     parameters:
 *       - name: stuId
 *         description: 种猪的ID
 *         in: path
 *         required: true
 *         type: integer
 *       - name: stuname
 *         description: 种猪的名字
 *         in: path
 *         required: true
 *         type: integer
 *     responses:
 *       200:
 *         description: 返回单个种猪
 *         schema:
 *           $ref: '#/definitions/StudentModel'
 */
router.get('/:stuId/:stuname', function(req, res, next) {
    let {stuId,stuname}=req.params
    res.json({'code':0,'msg':'查询成功','data':[
        {'id':stuId,'name':stuname,'gender':'男'},
       
    ]});
  });


//添加学生详细
/**
 * @swagger
 * /student/add:
 *   post:
 *     tags:
 *       - 种猪模块
 *     description: 添加种猪
 *     produces:
 *       - application/json
 *     parameters:
 *       - name: name
 *         description: 种猪的名字
 *         in: body
 *         required: true
 *         schema:
 *           $ref: '#/definitions/StudentModel'
 *     responses:
 *       200:
 *         description: 添加种猪
 */
router.post('/add', function(req, res, next) {
    let {name}=req.body
    res.json({'code':0,'msg':'添加成功','data':[
        {'id':'111','name':name,'gender':'gender'},
       
    ]});
  });


module.exports = router;
